#!/usr/bin/env python

PACKAGE="realsense_camera"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

#             Name                               Type      Level       Description                     Default    Min     Max
gen.add("enable_depth",                          bool_t,   0,          "Enable Depth",                 True)
gen.add("color_backlight_compensation",          int_t,    0,          "Backlight Compensation",       1,         0,      4)
gen.add("color_brightness",                      int_t,    0,          "Brightness",                   56,        0,      255)
gen.add("color_contrast",                        int_t,    0,          "Contrast",                     32,        16,     64)
gen.add("color_gain",                            int_t,    0,          "Gain",                         32,        0,      256)
gen.add("color_gamma",                           int_t,    0,          "Gamma",                        220,       100,    280)
gen.add("color_hue",                             int_t,    0,          "Hue",                          0,         -2200,  2200)
gen.add("color_saturation",                      int_t,    0,          "Saturation",                   128,       0,      255)
gen.add("color_sharpness",                       int_t,    0,          "Sharpness",                    0,         0,      7)

# Must be set only if color_enable_auto_white_balance is disabled
gen.add("color_white_balance",                   int_t,    0,          "White Balance",                6500,      2000,   8000)

# Must be set only if color_enable_auto_exposure is disabled
gen.add("color_exposure",                        int_t,    0,          "Exposure",                     156,       39,     10000)

# Must be set only if r200_lr_auto_exposure_enabled is disabled
gen.add("r200_lr_gain",                          int_t,    0,          "LR Gain",                      400,       100,    6399)
gen.add("r200_lr_exposure",                      int_t,    0,          "LR Exposure",                  164,       1,      164)

gen.add("color_enable_auto_white_balance",       int_t,    0,          "Enable Auto White Balance",    1,         0,      1)
gen.add("color_enable_auto_exposure",            int_t,    0,    	     "Enable Auto Exposure",         1,         0,      1)
gen.add("r200_lr_auto_exposure_enabled",         int_t,    0,          "Enable LR Auto Exposure",      0,         0,      1)

# The following edge parameters must be set only if r200_lr_auto_exposure_enabled is enabled
gen.add("r200_auto_exposure_top_edge",           int_t,    0,          "Auto Exposure Top Edge",       0,         0,      479)
gen.add("r200_auto_exposure_bottom_edge",        int_t,    0,          "Auto Exposure Bottom Edge",    479,       0,      479)
gen.add("r200_auto_exposure_left_edge",          int_t,    0,          "Auto Exposure Left Edge",      0,         0,      639)
gen.add("r200_auto_exposure_right_edge",         int_t,    0,          "Auto Exposure Right Edge",     639,       0,      639)

gen.add("r200_emitter_enabled",                  int_t,    0,          "Emitter Enabled",              1,         0,      1)

# Depth Control Grouping
r200_depth_control = gen.add_group("R200 Depth Control")
r200_dc_preset_enum = gen.enum(
  [ gen.const("UNUSED",     int_t,  -1, "Individual Depth Control was changed"),
    gen.const("Default",    int_t,  0,  "Default settings on chip. Similar to Medium. Best for Outdoors."),
    gen.const("Off",        int_t,  1,  "Disable almost all hardware-based outlier removal."),
    gen.const("Low",        int_t,  2,  "Lower number of outliers removed. Minimal false negatives."),
    gen.const("Medium",     int_t,  3,  "Medium number of outliers removed. Balanced approach."),
    gen.const("Optimized",  int_t,  4,  "Medium-High number of outliers removed. Derived optimization function."),
    gen.const("High",       int_t,  5,  "Higher number of outliers removed. Minimal false positives.")],
    "Depth Control Preset Choices")
#                      Name
#   Type      Level       Description                         Default   Min     Max     Method
r200_depth_control.add("r200_dc_preset",
    int_t,    64,         "R200 Depth Control Preset",        5,        -1,     5,      edit_method=r200_dc_preset_enum)
r200_depth_control.add("r200_dc_estimate_median_decrement",
    int_t,    32,         "Estimate Median Decrement",        5,        0,      255)
r200_depth_control.add("r200_dc_estimate_median_increment",
    int_t,    32,         "Estimate Median Increment",        5,        0,      255)
r200_depth_control.add("r200_dc_median_threshold",
    int_t,    32,         "Median Threshold",                 235,      0,      1023)
r200_depth_control.add("r200_dc_score_minimum_threshold",
    int_t,    32,         "Score Minimum Threshold",          27,       0,      1023)
r200_depth_control.add("r200_dc_score_maximum_threshold",
    int_t,    32,         "Score Maximum Threshold",          420,      0,      1023)
r200_depth_control.add("r200_dc_texture_count_threshold",
    int_t,    32,         "Texture Count Threshold",          8,        0,      31)
r200_depth_control.add("r200_dc_texture_difference_threshold",
    int_t,    32,         "Texture Difference Threshold",     80,       0,      1023)
r200_depth_control.add("r200_dc_second_peak_threshold",
    int_t,    32,         "Second Peak Threshold",            70,       0,      1023)
r200_depth_control.add("r200_dc_neighbor_threshold",
    int_t,    32,         "Neighbor Threshold",               90,       0,      1023)
r200_depth_control.add("r200_dc_lr_threshold",
    int_t,    32,         "LR Threshold",                     12,       0,      2047)

exit(gen.generate(PACKAGE, "realsense_camera", "r200_params"))
